Skip to content

Conversation

@DurgaPrasad-54
Copy link
Contributor

@DurgaPrasad-54 DurgaPrasad-54 commented Feb 3, 2026

Summary by CodeRabbit

  • Chores
    • Added a CI workflow to automatically sync API OpenAPI/Swagger JSON to the documentation repo.
    • Added a Swagger runtime profile and application settings to run the API for doc generation using an in-memory H2 database.
    • Adjusted runtime configuration so certain runtime services are disabled when running under the Swagger profile.

@coderabbitai
Copy link

coderabbitai bot commented Feb 3, 2026

Warning

Rate limit exceeded

@DurgaPrasad-54 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 19 minutes and 42 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📝 Walkthrough

Walkthrough

Adds a Swagger profile and a GitHub Actions workflow that builds the API, runs it to export /v3/api-docs as JSON, and opens a PR to update the AMRIT-Docs repo; also adds an H2 dependency and disables Redis and an HTTP interceptor when the swagger profile is active.

Changes

Cohort / File(s) Summary
GitHub Actions Workflow
​.github/workflows/swagger-json.yml
New workflow that checks out the API, sets up Java/Maven, builds (skip tests), runs the API with swagger profile, polls /v3/api-docs until valid JSON is returned, stops the API, checks out the AMRIT-Docs repo, copies ecd-api.json to docs/swagger/, and opens a PR with the update.
Dependency Management
pom.xml
Adds runtime-scoped dependency com.h2database:h2 to support an in-memory H2 datasource for the Swagger profile.
Spring Profile Exclusions
src/main/java/com/iemr/ecd/config/HttpInterceptorConfig.java, src/main/java/com/iemr/ecd/config/RedisConfig.java
Adds @Profile("!swagger") to both configuration classes so they are disabled when the swagger profile is active.
Swagger Profile Properties
src/main/resources/application-swagger.properties
New properties file configuring the swagger profile: in-memory H2 datasource, JPA settings, disabled security auto-config (for doc generation), CORS/logging settings, and placeholder JWT/URL values.

Sequence Diagram(s)

sequenceDiagram
  participant Actions as "GitHub Actions"
  participant Repo as "API repo (checkout)"
  participant Builder as "Java/Maven build"
  participant API as "ECD API (run with swagger)"
  participant jq as "jq/validator"
  participant DocsRepo as "AMRIT-Docs (checkout)"
  participant GitHub as "GitHub (create PR)"

  Actions->>Repo: checkout API code
  Actions->>Builder: setup Java 17 + Maven cache\nmvn -DskipTests package
  Actions->>API: run app with profile=swagger (port 9090)
  loop poll /v3/api-docs
    Actions->>API: GET /v3/api-docs
    API-->>Actions: JSON response
    Actions->>jq: validate & save as ecd-api.json
  end
  Actions->>API: stop process (kill PID)
  Actions->>DocsRepo: checkout AMRIT-Docs using token
  Actions->>DocsRepo: copy ecd-api.json -> docs/swagger/ecd-api.json\ncommit changes
  Actions->>GitHub: create pull request with commit/PR body
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Poem

🐰 I hopped through builds and JSON rays,
Polled docs until they shone like bays,
H2 for dreams, profiles set just right,
Pushed a PR into the night,
A tiny hop for docs — and delight! 🥕

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'chore(swagger): automate swagger sync to amrit-docs' accurately describes the main changes, which include automating the synchronization of Swagger documentation to the AMRIT-Docs repository via a new GitHub Actions workflow.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@src/main/resources/application-swagger.properties`:
- Line 24: The jwt.secret property value contains a leading space; update the
property key jwt.secret so its value has no leading or trailing whitespace
(change " JWT_SECRET" to "JWT_SECRET") to ensure the secret is read correctly by
the application (verify trim or no surrounding quotes if any).
🧹 Nitpick comments (1)
.github/workflows/swagger-json.yml (1)

37-56: Consider adding an initial delay before polling.

Spring Boot applications typically take 10-30 seconds to start. Adding an initial sleep before the polling loop could reduce unnecessary failed attempts and improve reliability.

Proposed improvement
       - name: Wait for API & fetch Swagger
         run: |
+          echo "Waiting for Spring Boot to initialize..."
+          sleep 15
           for i in {1..30}; do
             CODE=$(curl --connect-timeout 2 --max-time 5 -s -o swagger_raw.json -w "%{http_code}" http://localhost:9090/v3/api-docs || true)

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@src/main/resources/application-swagger.properties`:
- Line 9: The spring.jpa.hibernate.ddl-auto property is set to "none" which
causes failures on an empty in-memory H2 DB; change the value of
spring.jpa.hibernate.ddl-auto from "none" to "create-drop" (or "create") in the
application-swagger.properties so the schema is created at startup and removed
on shutdown, ensuring JPA entities and any `@PostConstruct/CommandLineRunner`
repository calls won't fail at boot.
🧹 Nitpick comments (4)
src/main/resources/application-swagger.properties (1)

11-13: Redis properties are unnecessary when RedisConfig is profile-excluded.

RedisConfig is annotated with @Profile("!swagger"), so no Redis beans are created under this profile. These properties are dead config. Removing them avoids confusion about whether Redis is actually used.

.github/workflows/swagger-json.yml (3)

3-6: Workflow triggers on every push to main — consider filtering by relevant paths.

Every merge to main (including doc-only or config changes) will trigger a full build + swagger export. Adding a paths filter reduces unnecessary CI runs.

Suggested filter
 on:
   push:
     branches: [ main ]
+    paths:
+      - 'src/**'
+      - 'pom.xml'
   workflow_dispatch:

27-28: jq is pre-installed on ubuntu-latest runners.

This step can be removed to save a few seconds. If you'd like to keep it for safety, that's fine too.


67-80: Process group kill (kill -- -$PID) may not work as intended.

$! captures the PID of the backgrounded java process, but kill -- -$PID sends a signal to the process group whose PGID equals $PID. In GitHub Actions, the background process may not be a process group leader, so this could silently miss. The fuser -k 9090/tcp fallback on line 80 covers it, but you could simplify:

Simplified stop logic
       - name: Stop API
         if: always()
         run: |
-          # Graceful shutdown of the process group
-          sleep 5
-          # Force kill the process group if still running
           if [ -f api_pid.txt ]; then
-              PID=$(cat api_pid.txt)
-              kill -TERM -- -"$PID" 2>/dev/null || true
-              sleep 2
-              kill -9 -- -"$PID" 2>/dev/null || true
-            fi
-            # Fallback: kill any remaining java process on port 9090
-            fuser -k 9090/tcp 2>/dev/null || true
+            PID=$(cat api_pid.txt)
+            kill "$PID" 2>/dev/null || true
+            sleep 5
+            kill -9 "$PID" 2>/dev/null || true
+          fi
+          fuser -k 9090/tcp 2>/dev/null || true

@sonarqubecloud
Copy link

@drtechie drtechie merged commit c1a95b3 into PSMRI:main Feb 11, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants